package com.ds.lens.data.service.dao;

import com.ds.lens.data.service.dao.entity.LensMonitorNotify;
import com.ds.lens.data.service.dao.sql.provider.LensMonitorNotifySqlProvider;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

@Repository
public interface LensMonitorNotifyDao {
    @Delete({
            "delete from lens_monitor_notify",
            "where monitor_id = #{id,jdbcType=BIGINT}"
    })
    int deleteByMonitorId(Long id);

    @InsertProvider(type = LensMonitorNotifySqlProvider.class, method = "insertSelective")
    int insertSelective(LensMonitorNotify record);

    @Select({
            "select",
            "id, title, renotify_time, monitor_id, content, ",
            " channel, channel_content ",
            "from lens_monitor_notify",
            "where monitor_id = #{id,jdbcType=BIGINT}"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "title", property = "title", jdbcType = JdbcType.VARCHAR),
            @Result(column = "renotify_time", property = "renotifyTime", jdbcType = JdbcType.INTEGER),
            @Result(column = "channel", property = "channel", jdbcType = JdbcType.INTEGER),
            @Result(column = "channel_content", property = "channelContent", jdbcType = JdbcType.VARCHAR),
            @Result(column = "monitor_id", property = "monitorId", jdbcType = JdbcType.BIGINT),
            @Result(column = "content", property = "content", jdbcType = JdbcType.LONGVARCHAR)
    })
    LensMonitorNotify selectByMonitorId(Long id);

    @UpdateProvider(type = LensMonitorNotifySqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(LensMonitorNotify record);

}
